<?php
function reequipment_adminapi_updateschedule($args)
{
    // Get arguments from argument array
    extract($args);

    // Get datbase setup
    $dbconn =& xarDBGetConn();
    $xartable =& xarDBGetTables();
    $table = $xartable['rescheduled'];
    $update = array();
    $bindvars = array();

    // Update item
    $query = "UPDATE $table SET ";
    if (isset($schedule_id)){
        $update[] = "schedule_id = ? ";
        $bindvars[] = $schedule_id;
    }
    if (isset($model_id)){
        $update[] = "model_id = ? ";
        $bindvars[] = $model_id;
    }
    if (isset($area_id)){
        $update[] = "area_id = ? ";
        $bindvars[] = $area_id;
    }
    if (isset($frequency_id)){
        $update[] = "frequency_id = ? ";
        $bindvars[] = $frequency_id;
    }
    if (isset($issue)){
        $update[] = "issue = ? ";
        $bindvars[] = $issue;
    }
    if (isset($item_ids)){
        $update[] = "item_ids = ? ";
        $bindvars[] = $item_ids;
    }
    if (isset($manhours)){
        $update[] = "manhours = ? ";
        $bindvars[] = $manhours;
    } 
    if (isset($downtime)){
        $update[] = "downtime = ? ";
        $bindvars[] = $downtime;
    }        
    $query .= join(",",$update);
    $query .= "WHERE schedule_id = ? ";
    $bindvars[] = $schedule_id;
    $result =& $dbconn->Execute($query, $bindvars);
    if (!$result) return;
    // Let any hooks know that we have created a new topic
    $args['module'] = 'reequipment';
    $args['itemtype'] = 3; //tag
    $args['itemid'] = $schedule_id;
    xarModCallHooks('item', 'update', $schedule_id, $args);
    // Return the id of the newly created link to the calling process
    return true;
}
?>